// pages/authorization/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
  
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  
  },
  updateUserInfo: function (options) {
    wx.request({
      url: getApp().globalData.API_URI + '/index.php/face_updateUserInfo',
      header: {//请求头  
        "Content-Type": "applciation/json"
      },
      data: {
        openid: getApp().globalData.openid,
        avatarUrl: options.avatarUrl,
        nickname: options.nickName,
        city: options.city,
        country: options.country,
        language: options.language,
        gender: options.gender,
        province: options.province
      },
      method: 'GET',
      success: function (e) {
        console.log(e)
      }
    })
  },
  onGotUserInfo: function (e) {
    console.log("============")
    console.log(e.detail.errMsg)
    console.log(e.detail.userInfo)
    console.log(e.detail.rawData)
    getApp().globalData.nickName = e.detail.userInfo.nickName;
    getApp().globalData.sex = e.detail.userInfo.sex;
    getApp().globalData.avatarUrl = e.detail.userInfo.avatarUrl;
    this.updateUserInfo(e.detail.userInfo);
    wx.navigateBack({
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})